Imports ToDoList.Model.TaskQuery

Namespace Model.TaskQuery
  Public Class SearchParent
    Inherits AbstractTaskQuery

    Private mTaskToFindParentFor As Task

    Public Sub New(ByVal taskToFindParentFor As Task)
      mTaskToFindParentFor = taskToFindParentFor
    End Sub

    ''' <summary>
    ''' Check to see if searched task is among children of given task
    ''' </summary>
    Public Overrides Sub Inspect(ByVal task As Task)

      'check to see if the searched task is among
      'the children of this task
      For Each lChildTask As Task In task.Tasks
        If lChildTask Is mTaskToFindParentFor Then
          'found!
          PublishResult(task)
          Exit For
        End If
      Next

    End Sub
  End Class
End Namespace